{template 'header'}
<link href="./resource/css/app.css" rel="stylesheet">
<ul class="nav nav-tabs">
    <li class="active"><a href="{php echo $this->createWeburl('question');}">常见问题管理</a></li>
    <li class=""><a href="{php echo $this->createWeburl('question', array('op' => 'addShow'));}">添加常见问题</a></li>
</ul>
<div class="panel panel-default">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th style="width:60px;">id</th>
                <th style="width:60px;">标题</th>
                <th style="width:80px;">内容</th>
                <th style="width:100px;">顺序</th>
                <th style="width:100px;">操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $question['list'] $item}
            <tr>
                <td>{$item['id']}</td>
                <td>{$item['title']}</td>
                <td>{$item['content']}</td>
                <td><input type="text" name="sort" class="sort" data-id="{$item['id']}" value="{$item['sort']}" style="width:60px;"></td>
                <td>
                    <a href="{php echo $this->createWeburl('question', array('op' => 'editShow', 'id' => $item['id']));}" class="btn btn-success btn-sm">编辑</a>&nbsp;
                    <a href="javascript:;" id="{$item['id']}" class="delete btn btn-danger btn-sm">删除</a>
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
    </div>
    {$rule['pages']}
</div>
{template 'footer'}
<script type="application/javascript">
    $(function () {
        $('.delete').click(function () {
            if (!confirm('确认要删除此分类?')) {
                return false;
            }
            id = $(this).attr('id');
            $.post('', {id:id, op:'delete'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')
        });


        $('.sort').blur(function () {
            var sort = $(this).val();
            var  id = $(this).data('id');
            $.post('', {id:id,sort:sort, op:'sort'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('排序失败');
                }

            }, 'json')
        });

        $('.settop').click(function () {
            id = $(this).data('id');
            $.post('', {id:id, op:'settop'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')
        });
    });

</script>